#include "loginscene.h"
#include "ui_loginscene.h"
#include "ui_reportdialog.h"
#include<QPainter>
#include"rightbutton.h"
#include<QDebug>
#include <qdebug.h>
#include"cancel.h"
#include<QFile>
#include<QWidget>
#include<QTimer>
#include "../../CheckTool/reporttool.h"
#include <iostream>

LoginScene::LoginScene(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LoginScene)
{
    ui->setupUi(this);

    //设置标题

    //确认按钮
    QPushButton* rightBtn=new QPushButton("确认");
    rightBtn->setGeometry(150,320,80,40);
    rightBtn->setParent(this);
//    rightBtn->move(130,280);


    //取消按钮
    QPushButton* cancelBtn=new QPushButton("取消");
    cancelBtn->setParent(this);
//    cancelBtn->move(438,270);
    cancelBtn->setGeometry(330,320,80,40);


    //行政区域的下拉框
    ui->comboBox1->addItem("湖北");
    ui->comboBox1->addItem("北京");
    ui->comboBox1->addItem("广西");
    ui->comboBox1->addItem("山东");


    //所属内型的下拉框
    ui->comboBox2->addItem("邮件检查");
    ui->comboBox2->addItem("虚拟机检查");
    ui->comboBox2->addItem("深度检查");
    ui->comboBox2->addItem("文件检查");


    //主机内型的下拉框
    ui->comboBox3->addItem("虚拟主机");
    ui->comboBox3->addItem("专享主机");
    ui->comboBox3->addItem("托管主机");
    ui->comboBox3->addItem("免费主机");
    ui->comboBox3->addItem("Linux主机");
    ui->comboBox3->addItem("Windows主机");


    ui->timeedit->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));//设置系统时间
    ui->timeedit->setReadOnly(true);//设置不可编辑
    ui->timeedit->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));//设置系统时间

    //确认按钮
    connect(rightBtn,&RightButton::clicked,[=](){



    myString_checkUnit=ui->checkUnit->text();

   myString_beCheckedUnit=ui->beCheckedUnit->text();
   myString_beCheckedPeople=ui->beCheckedPeople->text();
   myString_checkPeople=ui->checkPeople->text();
   myString_becheckedsection=ui->becheckedsection->text();



    myString_administrative_region=ui->comboBox1->currentText();
    myString_type=ui->comboBox2->currentText();
    myString_host_type=ui->comboBox3->currentText();

     time = ui->timeedit->text();//获取时间
     qDebug()<<strYear<<"年"<<strMonth<<"月"<<strDay<<"日"<<strHour<<"时"<<strMinute<<"分";
     ReportTool::GetInstance()->getdiologinfor(getinfors());//传回数据到reporttool
     accept();
    });

    //取消按钮
    connect(cancelBtn,&Cancel::clicked,[=](){
        reject();


    });

}
LoginScene::~LoginScene()
{
    delete ui;
}

//重新paintEvent事件 画背景图
void LoginScene::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QPixmap pix;
    pix.load(":/res/background.webp");
    painter.drawPixmap(0,0,this->width(),this->height(),pix);
}
Yzty::Maininfor LoginScene::getinfors()//读取对话框信息
{
    infors.check_unit = myString_checkUnit;
    infors.region = myString_administrative_region;
    infors.be_check_unit = myString_beCheckedUnit;
    infors.be_check_peo = myString_beCheckedPeople;
    infors.type = myString_type;
    infors.check_peo = myString_checkPeople;
    infors.check_time = time;
    infors.be_check_sec = myString_becheckedsection;
    infors.host_type = myString_host_type;
    return infors;
}
